<template>
	<view>
		<!-- <view class="top">
			<view class="title">基础设置</view>
		</view> -->
		<view class="con">
			<image :src="getHead(head_img)" @click="addCover" class="img"></image>
			<view class="text">
				<image class="addimg" src="../static/add_bg.png"></image>
				上传头像
			</view>
		</view>
		<view class="input">
			<!-- <input type="text" placeholder="输入你的昵称" v-model="nickname" /> -->
			<view class="box">
				<view class="list">
					<view class="item1">你的昵称</view>
					<view class="item2" style="margin-right:20rpx;">
						<input type="text" placeholder="输入你的昵称" v-model="nickname" />
					</view>
					<image class="right_go" src="../static/go.png" mode=""></image>
				</view>
				<view class="list">
					<view class="item1">手机号</view>
					<view class="item2" style="margin-right:20rpx;">{{user.telphone}}</view>	
				</view>
			</view>
		</view>
		<view class="button">
			<u-button @click="uploadIcon" class="u-button" :ripple="true" :hairLine="false" type="primary">确认提交</u-button>
		</view>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				nickname: '',
				head_img: "",
				user: {}
			}
		},
		onLoad(option) {
			than = this;
			uni.getStorage({
				key: 'user',
				success: function(e) {
					than.user = e.data;
					than.head_img = e.data.head_img;
					than.nickname = e.data.nickname;
				}
			})
		},
		methods: {
			addCover(id) {
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					success: function(res) {
						than.uploadPost("api/image/uploadMultiple", res.tempFilePaths[0], "file", function(data) {
							than.head_img = data.url
						})
					}
				});
			},
			uploadIcon() {
				than.post("api/user/uploadIcon", {
					head_img: than.head_img,
					nickname: than.nickname
				}, function(data) {
					than.user.head_img = than.head_img;
					than.user.nickname = than.nickname;
					uni.setStorage({
						key: 'user',
						data: than.user,
						success: function() {
							than.toast('保存成功')
							setTimeout(function() {
								uni.navigateBack()
							}, 1500);
						}
					})
				})
			}
		}
	}
</script>

<style lang="less">
	page{
		background: #FAFAFA;
	}
	.top {
		padding: 20rpx 50rpx 0rpx 50rpx;

		.title {
			font-size: 52rpx;
			font-weight: bold;
			color: #3F3F3F;
			margin-bottom: 50rpx;
		}
	}

	.con {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 400rpx;
		.img {
			width: 216rpx;
			height: 216rpx;
			border-radius: 50%;
		}

		.text {
			display: flex;
			align-items: center;
			background: #FDF4ED;
			border-radius: 30px;
			padding:10rpx 20rpx;
			font-size: 30rpx;
			font-weight: bold;		
            color: #3E3E3E;
			font-family: PingFang SC;
			margin-top: 20rpx;
			.addimg{
				width: 44rpx;
				height: 44rpx;
				margin-right:20rpx;
			}
		}
	}

	.input {
		padding: 0rpx 50rpx;
		margin-top: 100rpx;
		.box{
			 padding: 20rpx 0rpx;
			 background-color: white;
			 border-radius:20rpx;
			.list {
				height: 110rpx;
				border: 3rpx solid rgba(255, 255, 255, 0.26);
				border-radius: 12rpx;
				font-size: 32rpx;
				display: flex;
				align-items: center;
				font-weight: 500;
				color: #333333;
				padding: 0rpx 40rpx;
			
				.item1 {
					flex: 1;
				}
			
				.item2 {
					font-size: 28rpx;
					font-weight: 500;
					color: #999999;
					margin-right: 10rpx;
					input {
						border: none;
						text-align: right;
					}
				}
			
				.tx_box {
					height: 110rpx;
					width: 110rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}
			
				.right_go {
					margin-left: auto;
					width: 14rpx;
					height: 25rpx;
				}
			}
			
		}
 
		// input {
		// 	border: 1rpx solid #8E8E8E;
		// 	border-radius: 20rpx;
		// 	height: 100rpx;
		// 	text-align: center;
		// 	font-size: 32rpx;
		// 	font-family: PingFang SC;
		// 	font-weight: bold;
		// 	color: #9B9CA0;
		// }
	}

	.button {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 180rpx;

		.u-button {
			border: 0;
			width: 245rpx;
			height: 74rpx;
			// background: #FEC31D;
			// box-shadow: 0px 6px 8px 0px rgba(170, 170, 170, 0.16);
			// border-radius: 40rpx;	
			background: #FB683D;
			border-radius: 20rpx;
		}
	}
</style>
